package com.example.demo;

import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;

/**
 * Created by uc on 2018/10/18.
 */


public class AopMethod extends MethodVisitor implements Opcodes {
    public AopMethod(int api, MethodVisitor mv) {
        super(api, mv);
    }

    @Override
    public void visitCode() {
        super.visitCode();
        this.visitMethodInsn(INVOKESTATIC, "com/example/demo/AopInterceptor", "beforeInvoke", "()V");
    }

    @Override
    public void visitInsn(int opcode) {
        if (opcode == RETURN) {
            mv.visitMethodInsn(INVOKESTATIC, "com/example/demo/AopInterceptor", "afterInvoke", "()V");
        }
        super.visitInsn(opcode);
    }

}
    